home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / Technical.Notes / IIGS / TN.IIGS.089 < prev    next >
Encoding:
Text File  |  1990-09-21  |  4.3 KB  |  124 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6. Apple IIgs
  7. #89:    MessageByName--Catchy Messages
  8.  
  9. Written by:    Dan Strnad & Dave Lyons                         September 1990
  10.  
  11. This note clarifies MessageByName and provides examples of creating and 
  12. retrieving a named message.
  13. _____________________________________________________________________________
  14.  
  15.  
  16. Did You Say You Want To Get A Message?
  17.  
  18. All you have to do is ask.  Apple IIgs Toolbox Reference, Volume 3 already 
  19. tells you how.  Here's what the fine print says:  with the createItFlag set to 
  20. FALSE and the name of the message you are after in the nameString, you call 
  21. MessageByName.  What's unclear in the manual is that if the message was found, 
  22. no error is returned, the createFlag is returned as FALSE, and messageID 
  23. contains the ID you can pass to MessageCenter to retrieve the contents of the 
  24. message.  Here's an example of MessageByName in use.
  25.  
  26. The following code creates a named message.
  27.  
  28. CreateNamedMessage
  29.             pha
  30.             pha
  31.             pea 1                                     ;create it
  32.             pushlong #MsgBlock
  33.             _MessageByName                            ;function $1701
  34.             pla
  35.             sta myMsgID                               ;keep the ID if you want
  36.             pla                                       ;check the createFlag if 
  37. ;                                                      you want
  38.             ...
  39.  
  40. MsgBlock    dc.w MsgBlockEnd-MsgBlock
  41.             dc.b 28,'XYZ Software:My Cool Product'    ;Pascal-style string
  42.             ... more data goes here
  43. MsgBlockEnd
  44.  
  45. The following code retrieves the message.
  46.  
  47.             pha
  48.             pha
  49.             pea 0                                     ;don't create message
  50.             pushlong #MsgBlock
  51.             _MessageByName                            ;function $1701
  52.             ply                                       ;keep id of existing 
  53. ;                                                      message
  54.             pla                                       ;createFlag (ignore)
  55.             bcs noMessage                             ;carry set if an error 
  56. ;                                                      occurred
  57.  
  58.  
  59.             pea 2                                     ;MessageCenter action:GET
  60.             phy                                       ;message ID for 
  61. ;                                                      MessageCenter, below
  62.             pha
  63.             pha                                       ;space for NewHandle 
  64. ;                                                      result
  65.             lda #0                                    ;size of handle (0)
  66.             pha
  67.             pha
  68.             ldx MyID                                  ;ID for empty
  69.             phx
  70.             pha                                       ;handle attributes (0)
  71.             pha
  72.             pha                                       ;no special location
  73.             _NewHandle
  74.             lda 3,s
  75.             sta mcHandle+2
  76.             lda 1,s
  77.             sta mcHandle                              ;keep a copy of the 
  78. ;                                                      handle for later
  79.             _MessageCenter                            ;takes Action, Msg ID, 
  80. ;                                                      and Handle
  81.  
  82.             lda mcHandle+2
  83.             pha
  84.             lda mcHandle
  85.             pha
  86.             phd
  87.             tsc
  88.             tcd
  89.             ldy #2
  90.             lda [3],y
  91.             tax
  92.             lda [3]
  93.             sta 3
  94.             stx 5
  95.  
  96. * now read data from the message at [3]
  97.             ldy #$xxxx                                ;index past the name 
  98. ;                                                      string
  99.             lda [3],y
  100.             ...
  101.             pld
  102.             pla
  103.             pla
  104.             
  105.             lda mcHandle+2
  106.             pha
  107.             lda mcHandle
  108.             pha
  109.             _DisposeHandle
  110.  
  111. noMessage   ...
  112.  
  113. mcHandle    dc.l 0
  114. myMsgID     dc.w 0
  115.  
  116. MessageByName is available in Tool Locator versions 3.0 and later (System 
  117. Software 5.0 and later).
  118.  
  119.  
  120. Further Reference
  121. _____________________________________________________________________________
  122.   o  Apple IIgs Toolbox Reference, Volumes 2-3
  123.  
  124.